/*
 * @lc app=leetcode.cn id=2506 lang=cpp
 *
 * [2506] 统计相似字符串对的数目
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    int similarPairs(vector<string> &words)
    {
        vector<vector<bool>> v;
        for (auto &s : words)
        {
            vector<bool> tmp(26, false);
            for (auto c : s)
            {
                tmp[c - 'a'] = true;
            }
            v.push_back(tmp);
        }

        int ans = 0;

        for (size_t i = 0; i < v.size(); i++)
        {
            for (size_t j = i + 1; j < v.size(); j++)
            {
                auto &l = v[i];
                auto &r = v[j];
                bool flag = true;
                for (size_t k = 0; k < l.size(); k++)
                {
                    if (l[k] != r[k])
                    {
                        flag = false;
                        break;
                    }
                }
                ans += flag;
            }
        }
        return ans;
    }
};
// @lc code=end
